Example

> a = rand(3,3)
 a =
        1      0.333      0.665  
    0.975     0.0369     0.0847  
    0.647      0.162      0.204  
> trace(a)
     1.24
> 1+0.0369+0.204
     1.24
> trace(eye(5,5))
        5
See also: Page [*] sum().